<?php
$conexionbd=mysql_connect("localhost","root","") or die("Error en conexion.");
mysql_select_db("hossbd",$conexionbd) or  die("No se pudo seleccionar base de datos.");
$resultset = mysql_query($_REQUEST['query'],$conexionbd);

if(!$resultset)
{
	mysql_close();
	echo json_encode('error en el query: ' . mysql_error());
}
elseif(!mysql_num_rows($resultset))
{
	mysql_close();
	echo json_encode('Sin resultados');
}
else
{	
	
	while($row = mysql_fetch_assoc($resultset))
	{
		echo   "<h4>Puede modificar los datos</h4>";
		echo   "<form id='formulario' class='form-inline'  method='post' action='' onsubmit='actualizarDatosUsuario()'; return false>";
		echo   "<input id='nombre2' class='form-control' type='text' size='20' placeholder='Nombre(s)' maxlength='255' value=".$row['nombre'].">";
		echo   "<input id='apellido2' class='form-control' type='text' placeholder='Apellido(s)' maxlength='255' value=".$row['apellido'].">";
		echo   "<input id='cedula2' class='form-control' type='text' placeholder='C&eacute;dula' maxlength='255' value=".$row['cedula'].">";
		
		echo 	"<input type='checkbox' id='pass' class='checkbox' value='pass'><small>Reiniciar Contrase&ntilde;a</small></td>";
		echo "<br>";
		if($row['activo']==1) echo "<input type='checkbox' id='activo2' checked value='activo'><small> Usuario activo</small>";
	
		if($row['activo']==0) echo "<input type='checkbox' id='activo2' value='activo'><small> Usuario activo</small>";
		
		 echo   "<select class='form-control' id='roles' >";
		 echo "</select>";
		//$roles = array("ADMINISTRADOR","JEFE_DE_VENTAS","SUPERVISOR","ANALISTAS_CLIENTE","VENDEDOR","OPERADOR");

		for ($i = 1; $i <= 6; $i++) {
			if($row['rol']==$i)
				echo   "<option value=".$i." selected='selected'>".$roles[$i-1]."</option>";
			else 
				echo   "<option value=".$i.">".$roles[$i-1]."</option>";
		} 
		
		echo   "<td><input id='boton' type = 'button' class='btn btn-success' value= Actualizar onclick='actualizar(". $row['idusuarios'] .")'></td>";
		echo   "<td><input id='boton2' type = 'button' class='btn btn-warning' value= Cancelar onclick='cancelar()'></td>";
		echo 	"</form>";
	}

// 	<input id="nombre" name= "element_1_1" class="element text" maxlength="255" size="8" value=""/>
// 	<input id="apellido" name= "element_1_2" class="element text" maxlength="255" size="14" value=""/>
// 	<input id="cedula" name="element_2" class="element text medium" type="text" maxlength="255" value=""/>
// 	<input id="user" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>
// 	<input id="pass" name="element_4" class="element text medium" type="password" maxlength="255" value=""/>
// 	<select class="element select medium" id="roles" name="element_5">
// 	<option value="" selected="selected"></option>
// 	<option value="1" >ADMINISTRADOR</option>
// 	<option value="2" >JEFE_DE_VENTAS</option>
// 	<option value="3" >SUPERVISOR</option>
// 	<option value="4" >ANALISTAS_CLIENTE</option>
// 	<option value="5" >VENDEDOR</option>
// 	<option value="6" >OPERADOR</option>
// 	</select>
// 	<label class="description" for="activo">Usuario Activo</label>
// 	<input type="checkbox" name="activo" value="Activo" id="activo" checked>
// 	<input id="enviar"  type="submit" name="submit" value="Actualizar" />

	mysql_close();
}
?>